package com.platform.qujia.service.impl;

import com.platform.qujia.dao.OilPriceMapper;
import com.platform.qujia.dao.StationMapper;
import com.platform.qujia.pojo.OilPriceInfo;
import com.platform.qujia.pojo.OilPriceVO;
import com.platform.qujia.pojo.Station;
import com.platform.qujia.service.OilPriceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class OilPriceServiceImpl implements OilPriceService {

    @Resource
    private OilPriceMapper oilPriceMapper;

    @Resource
    private StationMapper stationMapper;

    public OilPriceInfo getOilPrice(String stationId){
        List<OilPriceVO> oilPriceVOS = oilPriceMapper.selectOilPrice(stationId);

        //油站地址
        Station station = stationMapper.selectStationById(Integer.valueOf(stationId));
        OilPriceInfo build = OilPriceInfo.builder()
                .oilPriceList(oilPriceVOS)
                .stationAddress(station.getDetailRegionData())
                .stationPhone(station.getPhone())
                .build();

        return build;

    }
}
